#include "stdafx.h"
#include "TestSnout.h"
#include "UESnout.h"
#include "UEEntityOperation.h"

CPPUNIT_TEST_SUITE_REGISTRATION( TestSnout );


TestSnout::TestSnout()
{
}


TestSnout::~TestSnout()
{
}
#include "UECirque.h"
void TestSnout::testCreate()
{
	AcGePoint3d BottomCenter;
	AcGeVector3d BottomDir;
	double dRBottom;
	double dRTop;
	double dHeight;
	double dXAngleOff;
	double dAngleOff;

	BottomCenter.set( 500, 200, 300 );
	BottomDir.set( 1, 0, 0 );
	dRBottom = 500;
	dRTop = 200;
	dHeight = 300;
	dXAngleOff = PI;
	dAngleOff = PI/2.0;

	CUESnout Snout( BottomCenter, BottomDir, dRBottom, dRTop, dHeight, dXAngleOff );

	AcDb3dSolid* pSolid = NULL;
	try
	{
	    pSolid = Snout.Create();
	}
	catch ( CString& strError )
	{
	    CPPUNIT_NS::Asserter::fail( (LPCTSTR)strError );
	}
	
	Acad::ErrorStatus es = CUEEntityOperation::AddEntityToDwg( pSolid );
	
	if ( es != Acad::eOk )
	{
	    delete pSolid;
	}
	
	pSolid->close();
}

void TestSnout::testErrorCreate()
{
	AcGePoint3d BottomCenter;
	AcGeVector3d BottomDir;
	double dRBottom;
	double dRTop;
	double dHeight;
	double dXAngleOff;
	double dAngleOff;

	BottomCenter.set( 0, 0, 0 );
	BottomDir.set( 0, 1, 0 );
	dRBottom = 500;
	dRTop = 200;
	dHeight = 1e-3;
	dXAngleOff = -2.0 * PI;
	dAngleOff = PI/2.0;

	CUESnout Snout( BottomCenter, BottomDir, dRBottom, dRTop, dHeight, dXAngleOff );

	AcDb3dSolid* pSolid = NULL;
	try
	{
	    pSolid = Snout.Create();
	}
	catch ( CString& strError )
	{
	    CPPUNIT_NS::Asserter::fail( (LPCTSTR)strError );
	}
	
	Acad::ErrorStatus es = CUEEntityOperation::AddEntityToDwg( pSolid );
	
	if ( es != Acad::eOk )
	{
	    delete pSolid;
	}
	
	pSolid->close();
}
